package com.example.tianyidemo.controller;
import com.example.tianyidemo.pojo.EmailCode;
import com.example.tianyidemo.pojo.Result;
import com.example.tianyidemo.service.EmailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
//发送注册信息
@Slf4j
@CrossOrigin//准许跨域请求
@RestController//包含@Controller（三层架构声明控制器）和@ResponseBody（转化json格式）
public class EnrollController {
    @Autowired
    private EmailService emailService;
    @PostMapping("/enroll")
    public Result Enroll(@RequestBody EmailCode email){
        log.info("注册：{}",email);
        EmailCode e = emailService.enroll(email);
        return Result.success();
    }
}
